package com.bocai.freeman.view.activitys;

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bocai.freeman.R;
import com.bocai.freeman.base.BaseActivity;
import com.bocai.freeman.utils.ToolbarHelper;
import com.bocai.freeman.view.custom.MRatingBar;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by win7 on 2016/5/23.
 */
public class SpecialDetailNoPayActivity extends BaseActivity implements ValueAnimator.AnimatorUpdateListener {
    @Bind(R.id.tv_type)
    TextView tvType;
    @Bind(R.id.img_dismiss)
    ImageView imgDismiss;
    @Bind(R.id.ll_detail_type)
    LinearLayout llDetailType;
    @Bind(R.id.rvice_start)
    MRatingBar rviceStart;
    @Bind(R.id.ll_evaluate)
    LinearLayout llEvaluate;
    @Bind(R.id.ll_pay)
    LinearLayout llPay;
    @Bind(R.id.ll)
    LinearLayout ll;
    private ValueAnimator mAnimator;
    private ViewGroup.LayoutParams mLayoutParams;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_special_perf_detail);
        ButterKnife.bind(this);
        ToolbarHelper.setup(this, getString(R.string.str_order_detail), R.mipmap.left_return, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        initView();
        initEvent();
    }

    @Override
    protected void initView() {
        tvType.setText("未支付");
        llEvaluate.setVisibility(View.GONE);
    }

    @Override
    protected void initEvent() {
        click(imgDismiss).subscribe(o -> hide());
    }

    /**
     * 隐藏提示
     */
    private void hide() {
        mLayoutParams = llDetailType.getLayoutParams();
        mAnimator = ValueAnimator.ofInt(llDetailType.getHeight(), 0);
        mAnimator.addUpdateListener(this);
        mAnimator.setDuration(200);//设置动画持续时间
        mAnimator.start();
    }

    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
        int value = (Integer) animation.getAnimatedValue();
        mLayoutParams.height = value;
        llDetailType.setLayoutParams(mLayoutParams);
    }
}
